//
//  MTSearchFriendAddCell.swift
//  MT
//
//  Created by ooops on 2020/5/17.
//  Copyright © 2020 张强. All rights reserved.
//

import Foundation
import MTCategory
import Kingfisher

protocol MTSearchFriendAddCellDelegate: NSObjectProtocol {
    
    func didClickedAddFriendButton(sender: UIButton)
    
}

class MTSearchFriendAddCell: UITableViewCell {
    
    class func reuseIdentity() -> String {
        return "MTSearchFriendAddCellID"
    }
    
    weak var delegate: MTSearchFriendAddCellDelegate?
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupUI()
        makeConstraint()
        selectionStyle = .none
        contentView.backgroundColor = .clear
        backgroundColor = .clear
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    lazy var addFriendButton: UIButton = {
        let btn = UIButton(type: .custom)
        btn.setTitle("加为好友", for: .normal)
        btn.addTarget(self, action: #selector(didClickedAddFriendButton(sender:)), for: .touchUpInside)
        btn.setTitleColor(.white, for: .normal)
        btn.titleLabel?.font = PingFangSCSemiboldFont(16)
        btn.layer.cornerRadius = 25
        btn.layer.masksToBounds = true
        btn.backgroundColor = UIColor(hex: 0xffc000)
        return btn
    }()
    
    @objc private func didClickedAddFriendButton(sender: UIButton) {
        self.delegate?.didClickedAddFriendButton(sender: sender)
    }
    
    private func setupUI() {
        contentView.addSubview(addFriendButton)
    }
    
    private func makeConstraint() {
        addFriendButton.snp.makeConstraints { (make) in
            make.center.equalToSuperview()
            make.size.equalTo(CGSize(width: 332, height: 50))
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
